<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('追溯监管复核')" />
</head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>

                        <li class="select-time">
                            <label>时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="查询时间" name="sellStartTime"/>
                           <span>-</span>
                           <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="sellEndTime"/>
                        </li>

                        <!-- <li>
                             拼音码：<input type="text" name="plucode" th:placeholder="条码"/>
                         </li>-->
<!--                        <li>
                            商品名称：<input type="text" name="goodsname" th:placeholder="商品名称"/>
                        </li>-->

<!--                        <li>
                            药品类型：<select name="classname"  id="deviceType">
                            <option value="">-&#45;&#45;请选择-&#45;&#45;</option>
                            <option value="中成药类">中成药类</option>
                            &lt;!&ndash;                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>&ndash;&gt;
                            &lt;!&ndash; <option th:each="deviceType : ${deviceTypeList}" th:text="${deviceType}" th:value="${deviceType}"></option>&ndash;&gt;
                            &lt;!&ndash;<option value="食品类">食品类</option>&ndash;&gt;
                            <option value="西药类">西药类</option>
                            &lt;!&ndash;<option value="参茸类">参茸类</option>&ndash;&gt;
                            &lt;!&ndash;<option value="医疗器械类">医疗器械类</option>&ndash;&gt;
                            &lt;!&ndash;<option value="饮片类">饮片类</option>&ndash;&gt;
                            <option value="进口药品类">进口药品类</option>
                            &lt;!&ndash;<option value="计生用品类">计生用品类</option>&ndash;&gt;
                            &lt;!&ndash;<option value="西药类">西药类</option>&ndash;&gt;
                            &lt;!&ndash;<option value="生物制品">生物制品</option>&ndash;&gt;

                        </select>
                        </li>-->

                        <li hidden>
                            <input id="flag3" name="flag3" value="1"></input>
                        </li>
                        <!--                        <li>
                                                    客户名称：<input type="text" name="companyName"/>
                                                </li>-->
                        <!--  <li>
                              岗位状态：<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
                              <option value="">所有</option>
                              <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                          </select>
                          </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>

                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--            <a class="btn btn-success" onclick="$.operate.add()" >
                            <i class="fa fa-plus"></i> 新增
                        </a>-->
<!--            <a class="btn btn-success" onclick="link()" >
                <i class="fa"></i> 新增药品关系
            </a>-->
            <!--            <a class="btn btn-success" onclick="recommend()" >
                            <i class="fa"></i> 新增为推荐
                        </a>-->
            <!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:post:edit">
                            <i class="fa fa-edit"></i> 修改
                        </a>-->
            <!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:post:remove">
                            <i class="fa fa-remove"></i> 删除
                        </a>-->
            <!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:post:export">
                            <i class="fa fa-download"></i> 导出
                        </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
    <!--    <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="post-form1">
                    <div class="select-list">
                        <ul>
                            <li>
                                药品信息：<input type="text" name="plucode" th:placeholder="店内码或拼音码"/>
                            </li>
                            &lt;!&ndash;                        <li>
                                                        客户名称：<input type="text" name="companyName"/>
                                                    </li>&ndash;&gt;
                            &lt;!&ndash;  <li>
                                  岗位状态：<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
                                  <option value="">所有</option>
                                  <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                              </select>
                              </li>&ndash;&gt;
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>-->

    <!--        <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" >
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:post:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:post:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:post:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->

    <!--        <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table1"></table>
            </div>-->
</div>
</div>


<th:block th:include="include :: footer" />
<script th:inline="javascript">
    //  var editFlag = [[${@permission.hasPermi('system:post:edit')}]];
    // var removeFlag = [[${@permission.hasPermi('system:post:remove')}]];
    var datas = [[${@dict.getType('sys_normal_disable')}]];
    var prefix = ctx + "baodao/review";

    // 日期初始化
    layui.use(['laydate'], function(){
        //var laydate = layui.laydate;
        //执行一个laydate实例
        layui.laydate.render({
            elem: '#startTime'
            ,value: new Date(), // 指定值
        });

        layui.laydate.render({
            elem: '#endTime'
            ,value: new Date(), // 指定值
        });
    });

    $(function() {
        query();
    });
</script>

<script>
    function query() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            updateUrl: prefix + "/detail/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            /*  sortName: "companyId",*/
            modalName: "药品关系",
            // 测试父子表
            detailView: false,
            // 测试新增 查询条件
            /*queryParams: function(params) {
                 var curParams = {
                     // 传递参数查询参数
                     pageSize: params.limit,
                     pageNum: params.offset / params.limit + 1,
                     searchValue: params.search,
                     orderByColumn: params.sort,
                     isAsc: params.order,
                     // 新增 flag 为0 展示全部 药品信息，为1 展示药品关联表中已建立关系的药品列表
                     //   flag:  $("#flag").val()

                     sellStartTime:"",
                     sellEndTime:"",

                     flag: 0
                 }
                 return curParams;
             },*/
            columns: [
                /*{
                    field: 'no',
                    title: '序号',
                    // sortable: true,
                    //  align: "center",
                    width: 60,
                    formatter: function (value, row, index) {
                        /!*  //获取每页显示的数量
                          var pageSize = $('#table').bootstrapTable('getOptions').pageSize;
                          //获取当前是第几页
                          var pageNumber = $('#table').bootstrapTable('getOptions').pageNumber;
                          //返回序号，注意index是从0开始的，所以要加上1
                          return pageSize * (pageNumber - 1) + index + 1;*!/
                        return index + 1;
                    }
                },*/
                {
                    field: 'sellDate',
                    title: '销售时间'
                },
                {
                    field: 'sellNo',
                    title: '票号'
                },

                {
                    field: 'totalQtum',
                    title: '交易金额'
                },
                {
                    field: 'goodsNum',
                    title: '商品数量'
                },{
                    field: 'zsNum',
                    title: '追溯数量'
                },
                {
                    field: 'cy',
                    title: '差异',
                    formatter: function(value, row, index) {
                        let cy = row.goodsNum - row.zsNum;
                        if(cy != '0') {
                            cy = '<span style="color: red">' + cy + '</span>'
                        }

                        return cy;
                    }
                },{
                    field: 'shopName',
                    title: '店铺名称',
                },
                {
                    field: 'faceId',
                    title: '人脸',
                    visible: false,
                },
                {
                    field: 'startTime',
                    title: '交易开始时间'
                },
                {
                    field: 'endTime',
                    title: '交易结束时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        /* actions.push('<a class="btn btn-info  btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.goodscode + '\')"><i class="fa fa-plus"></i>新增</a> ');row.sellNo + row.startTime + row.endTime*/
                        actions.push('<a class="btn btn-success btn-xs ' + "editFlag" + '" href="javascript:void(0)" onclick="detail(\'' + row.sellNo +"','"+ row.startTime+ "','"+ row.endTime+ '\')"><i class="fa fa-edit"></i>查询</a> ');
                        /* actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.postId + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        // actions.push('<a class="btn btn-danger btn-xs ' + "removeFlag" + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.goodscode + '\')"><i class="fa fa-remove"></i>删除</a>');
                        //actions.push('<a class="btn btn-danger btn-xs ' + "removeFlag" + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.goodscode + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }
            ]

        };
        $.table.init(options);
    }


    function detail(sellNo,startTime,endTime) {
        table.set();


        let url = ctx + 'baodao/review/detail/' + sellNo+"?startTime="+startTime+"&endTime="+endTime;
        console.log("弹窗 url" + url)
        var result = url.replace(/#/g, '%23');
        //$.modal.openFull("复核详细信息",result);

        // 弹出即全屏
        var index = layer.open({
            type: 2,
            title: '复核详细信息',
            content: result,
            area: ['1000px', '600px'],
            maxmin: true
        });
        layer.full(index);

        //$.modal.openTab("复核详细信息",result);

        //$.modal.openTab("修改" + table.options.modalName, $.operate.editUrl(id));

    }

</script>
</body>
</html>
